package com.ljkj.blockpay.ui.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;

import com.kongzue.baseokhttp.util.JsonList;
import com.kongzue.baseokhttp.util.JsonMap;
import com.ljkj.blockpay.R;
import com.ljkj.blockpay.basedata.BaseActivity;
import com.ljkj.blockpay.databinding.ActivitySelectCurrencyBinding;
import com.ljkj.blockpay.model.RechargeModel;
import com.ljkj.blockpay.presenter.SelectCurrencyPresenter;
import com.ljkj.blockpay.presenter.inter.SelectCurrencyInter;
import com.ljkj.blockpay.ui.adapter.CommonSelectAdapter;
import com.ljkj.blockpay.widget.ClickListener;

import java.util.Collections;
import java.util.List;

/**
 * 币种选择页面
 */
public class SelectCurrencyActivity extends BaseActivity<ActivitySelectCurrencyBinding,SelectCurrencyPresenter> implements SelectCurrencyInter.SelectCurrencyInterView {

    private CommonSelectAdapter mConnomAdapter;
    @Override
    public int initContentView() {
        return R.layout.activity_select_currency;
    }
    @Override
    protected SelectCurrencyPresenter createPresenter() {
        return new SelectCurrencyPresenter(this,this);
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        binding.tvTitle.setTitleContent(R.string.selectcurrency_text);
        binding.tvTitle.setLeftBackFinish(this);

    }

    @Override
    protected void initData() {
        super.initData();
        getPresenter().getNetAccuracy(1);
        binding.rvCurrencylist.setLayoutManager(new LinearLayoutManager(this));
        mConnomAdapter = new CommonSelectAdapter(R.layout.currencyselect_layout);
        binding.rvCurrencylist.setAdapter(mConnomAdapter);
        mConnomAdapter.setOnItemClickListener((adapter, view1, position) ->{
            Intent intent = getIntent();
            JsonList jsonList = (JsonList) mConnomAdapter.getData();
            intent.putExtra("jsonMap",jsonList.getJsonMap(position).toString());
            setResult(100,intent);
            finish();
        });
    }



    @Override
    public void showNetAccuracy(JsonList jsonMap) {
        mConnomAdapter.setNewInstance(jsonMap);
    }
}